package com.be.beadmin.design.util;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.util.ListUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class ExcelListener<T> extends AnalysisEventListener<T> {

    private List<T> cachedDataList =  ListUtils.newArrayList();
    @Override
    public void invoke(T data, AnalysisContext analysisContext) {
        cachedDataList.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
//        System.out.println("解析完成");
    }

    /**
     * 返回数据
     *
     * @return 返回读取的数据集合
     **/
    public List<T> getDatas() {
        return cachedDataList;
    }

    /**
     * 设置读取的数据集合
     *
     * @param datas 设置读取的数据集合
     **/
    public void setDatas(List<T> datas) {
        this.cachedDataList = datas;
    }

}
